package com.jjtm.common.core.utils;


import com.jjtm.common.core.constants.ErrorConstants;

/**
 * @author 吃人
 * @date 2020/1/15
 */
public class ResultUtil {

    public static JsonResult success() {
        return new JsonResult(ErrorConstants.BUG_SUC, true, "请求成功");
    }

    public static JsonResult success(Object object) {
        return new JsonResult(ErrorConstants.BUG_SUC, true, "请求成功", object);
    }

    public static JsonResult success(String msg, Object object) {
        return new JsonResult(ErrorConstants.BUG_SUC, true, msg, object);
    }

    public static JsonResult errorNotLogin() {
        return new JsonResult(ErrorConstants.NOT_LOGIN, false, "请登录");
    }


    public static JsonResult error(String msg) {
        return new JsonResult(ErrorConstants.BUG_ERR, false, msg);
    }

    public static JsonResult error() {
        return new JsonResult(ErrorConstants.BUG_ERR, false, "请求超时");
    }

    /**
     * 返回异常信息，在已知的范围内
     */
    public static JsonResult error(Object data) {
        JsonResult result = new JsonResult();
        result.setCode(ErrorConstants.BUG_ERR);
        result.setMsg("参数错误");
        result.setData(data);
        return result;
    }

}
